package com.unknowpupil.design.observer;

/**
 * @Description: <p>
 *
 * </p>
 * @Author: <a> w10g </a>
 * @CreateDate: Create in 2020/4/28 16:34
 * @Classname: Client
 * @Version: 1.0
 */
public class Client {
    public static void main(String[] args) {
        //场景目标对象
        ConcreteSubject concreteSubject = new ConcreteSubject();
        //场景多个观察者
        ObserverA observer1 = new ObserverA();
        ObserverA observer2 = new ObserverA();
        ObserverA observer3 = new ObserverA();
        //将者三个观察者添加到subject对象的观察者队伍中
        concreteSubject.registerObserver(observer1);
        concreteSubject.registerObserver(observer2);
        concreteSubject.registerObserver(observer3);
        //改变状态 这里广播所有的都变化
        concreteSubject.setState(300);
        System.out.println("************");

        System.out.println(observer1.getMyState());
        System.out.println(observer2.getMyState());
        System.out.println(observer3.getMyState());
    }
}
